﻿<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Management.Master" CodeBehind="Calendar.aspx.vb" Inherits="BooksReviewApp.Calendar" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>

        
    <div class="mainDiv"> 
    <h2>Calendar</h2>
    <br />
    <h3 id="myHeading" runat="server">
    </h3>
        <br />
    <asp:Calendar ID="Montly_Calendar" runat="server" BorderColor="#CCCCCC" FirstDayOfWeek="Monday" NextPrevFormat="ShortMonth">
    </asp:Calendar>
    <br />
    <br />
        <h2 id="myHeading_Appointments" runat="server"></h2>
        <br />
        
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="SqlDataSource1" AllowPaging="True" PageSize="5">
            <Columns>
                <asp:BoundField DataField="EventName" HeaderText="Appointment" SortExpression="EventName">
                <HeaderStyle ForeColor="#7AC0DA" HorizontalAlign="Center" />
                <ItemStyle HorizontalAlign="Justify" Width="100px" />
                </asp:BoundField>
                <asp:TemplateField HeaderText="Time" SortExpression="EventTime">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("EventTime") %>'></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("EventTime") %>'></asp:Label>
                    </ItemTemplate>
                    <HeaderStyle ForeColor="#7AC0DA" HorizontalAlign="Center" Width="35px" />
                    <ItemStyle HorizontalAlign="Center" Width="35px" />
                </asp:TemplateField>
                <asp:BoundField DataField="EventDescription" HeaderText="Description" SortExpression="EventDescription" >
                <HeaderStyle ForeColor="#7AC0DA" Width="200px" HorizontalAlign="Center" />
                </asp:BoundField>
                <asp:CommandField ShowDeleteButton="True" >
                <ItemStyle CssClass="deleteLinkButton" />
                </asp:CommandField>
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:BooksReviewDBConnectionString1 %>" SelectCommand="SELECT * FROM [Appointments] WHERE ([EventDate] = @EventDate) ORDER BY [EventDate]" deletecommand="DELETE FROM [Appointments] WHERE [ID] = @ID" InsertCommand="INSERT INTO [Appointments] ([EventName], [EventTime], [EventDescription], [EventDate]) VALUES (@EventName, @EventTime, @EventDescription, @EventDate)" UpdateCommand="UPDATE [Appointments] SET [EventName] = @EventName, [EventTime] = @EventTime, [EventDescription] = @EventDescription, [EventDate] = @EventDate WHERE [ID] = @ID">
            <DeleteParameters>
                <asp:Parameter Name="ID" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="EventName" Type="String" />
                <asp:Parameter Name="EventTime" Type="Int32" />
                <asp:Parameter Name="EventDescription" Type="String" />
                <asp:Parameter DbType="Date" Name="EventDate" />
            </InsertParameters>
            <SelectParameters>
                <asp:ControlParameter ControlID="Montly_Calendar" DbType="Date" Name="EventDate" PropertyName="SelectedDate" />
            </SelectParameters>
            <UpdateParameters>
                <asp:Parameter Name="EventName" Type="String" />
                <asp:Parameter Name="EventTime" Type="Int32" />
                <asp:Parameter Name="EventDescription" Type="String" />
                <asp:Parameter DbType="Date" Name="EventDate" />
                <asp:Parameter Name="ID" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>

        <br />
    </div>
    <div class="asideCentered">
        <br />
        <br />
        <br />
        
        <br />
    <asp:PlaceHolder Visible ="False" runat="server" ID="Add_Appointment">
        <h3>Add an Appointment</h3>
        <br />
        <table>
            <tr>
                <td>
                    Event Name
                </td>
                <td>
                    <asp:TextBox ID="tb_eventName" runat="server"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="tb_eventName"
                        CssClass="field-validation-error" ErrorMessage="*"></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td>
                    Time
                </td>
                <td>
                    <asp:DropDownList ID="ddl_Time" runat="server">
            <asp:ListItem Selected="True" Value="8">08:00</asp:ListItem>
            <asp:ListItem Value="9">09:00</asp:ListItem>
            <asp:ListItem Value="10">10:00</asp:ListItem>
            <asp:ListItem Value="11">11:00</asp:ListItem>
            <asp:ListItem Value="12">12:00</asp:ListItem>
            <asp:ListItem Value="13">13:00</asp:ListItem>
            <asp:ListItem Value="14">14:00</asp:ListItem>
            <asp:ListItem Value="15">15:00</asp:ListItem>
            <asp:ListItem Value="16">16:00</asp:ListItem>
            <asp:ListItem Value="17">17:00</asp:ListItem>
            <asp:ListItem Value="18">18:00</asp:ListItem>
            <asp:ListItem Value="19">19:00</asp:ListItem>
            <asp:ListItem Value="20">20:00</asp:ListItem>
            <asp:ListItem Value="21">21:00</asp:ListItem>
        </asp:DropDownList>
                    </td>
                </tr>
            <tr>
                <td>
                    Description
                </td>
                <td>
                    <asp:TextBox ID="tb_Description" runat="server" TextMode="MultiLine" Width="300px" Height="120px"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="tb_Description"
                        CssClass="field-validation-error" ErrorMessage="*"></asp:RequiredFieldValidator>
                </td>
            </tr>
            </table>
        <asp:Button ID="btn_AddAppointment" runat="server" Text="Add Appointment" CssClass="m-btn blue" />

    </asp:PlaceHolder>
    </div>
            </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
